package com.sskj.b70.p.fragment;

import com.lzy.okgo.OkGo;
import com.sskj.b70.m.HttpConfig;
import com.sskj.b70.m.bean.HttpData;
import com.sskj.b70.m.bean.bean.Stock;
import com.sskj.b70.m.http.JsonCallBack;
import com.sskj.b70.p.base.BasePresenter;
import com.sskj.b70.v.fragment.ChartFragment;

import java.util.List;

/**
 * ProjectName：new_bfex
 * DESC: (类描述)
 * Created by 李岩 on 2018/7/5 0005
 * updateName:(修改人名称)
 * updateTime:(修改时间)
 * updateDesc:(修改内容)
 */
public class ChartPresenter extends BasePresenter<ChartFragment> {

    /**
     * 获取股票K线
     *
     * @param
     * @param (/minute5/minute15/minute30/minute60/day)
     * @param code                                            (BCH_USDT/ETC_USDT/ETH_USDT/BTC_USDT/LTC_USDT )
     * @param
     * @param
     */
    public void getStockInfo(String timeCycle, String code, boolean update) {
        OkGo.<HttpData<List<Stock>>>get(HttpConfig.BASE_URL + HttpConfig.GOODS_INFO)
//        OkGo.<HttpData<List<Stock>>>get("http://admin.sanwan1688.com/app/interface?app=app&action=goodsHistoryInfoGet&code=HSIF&goodsType=minute5")
                .params("type", 2)
                .params("timeCycle", timeCycle)
                .params("code", code)
                .execute(new JsonCallBack<HttpData<List<Stock>>>(this, false) {
                    @Override
                    public void _onSuccess(com.lzy.okgo.model.Response<HttpData<List<Stock>>> response) {
                        List<Stock> stockList = response.body().getData();
                        mView.setChart(stockList, update);
                    }
                });
    }

    /**
     * 获取交易币数据
     */
    public void getTime(String goodsType, String code, boolean update) {
        OkGo.<HttpData<List<Stock>>>get(HttpConfig.BASE_URL + "/Home/test/index")
                .params("goodsType", goodsType)
                .params("code", code)
                .execute(new JsonCallBack<HttpData<List<Stock>>>(this, false) {
                    @Override
                    public void _onSuccess(com.lzy.okgo.model.Response<HttpData<List<Stock>>> response) {
                        List<Stock> stocks = response.body().getData();
                        mView.setChart(stocks, update);
                    }
                });
    }

}
